/**
 * @class MyNamespace.Login
 * @extends extendsClass
 * Description
 */
Ext.define('MyApp.view.Login', {
    extend: 'Ext.form.Panel',
    //alternateClassName: ''
    xtype: 'login',

    requires: [
        'Ext.field.Text',
        'Ext.field.Password',
        'Ext.field.Checkbox'
    ],

    config: {
    	cls: 'login-view',

    	layout: {
    		type: 'vbox', //hbox
            align: 'center',
            pack: 'center'
    	},
    	defaults: {
			margin: '0 0 2em 0'
    	},

        items: [{
        	xtype: "component",
        	cls: 'applogo'
        }, {
        	xtype: 'container',
        	itemId: 'xxx',
        	margin: '0',
        	items: [
                    {
                        xtype: 'textfield',
                        label: '&nbsp;',
                        labelWidth: 'auto',
                        placeHolder: '用户名',
                        name: 'username',
                        cls: 'username'
                    },
                    {
                        xtype: 'passwordfield',
                        label: '&nbsp;',
                        labelWidth: 'auto',
                        placeHolder: '密码',
                        name: 'password',
                        cls: 'password'
                    }
                ]
        },
        {
        	xtype: 'container',
        	margin: '0',
        	width: '100%',
        	layout: {
        		type: 'vbox',
        		align: 'left'
        	},
        	items: [{
            	xtype: 'checkboxfield',
	            cls: 'rempsw',
	            label: '记住密码',
	            labelAlign: 'right',
	            labelWidth: 'auto',
	            name: 'rempsw',
	            checked: true
            }]
        },
        {
            xtype: 'button',
            ui: 'blue',
            itemId: 'btnLogin',
            width: '80%',
            text: '登录',
            margin: '0'
        }]

        /*,listeners: [{
        	event: 'initialize',
        	fn: 'onInit'
        },{
        	delegate: 'button#btnLogin',
        	event: 'tap',
        	fn: 'onLoginTap'
        }]*/
    },

    initialize: function () {
    	this.callParent(arguments);

    	this.on({
    		initialize: 'onInit',
    		scope: this
    	});

    	//this.down('button#btnLogin').on('tap', 'onLoginTap', this);
    	this.down('button#btnLogin').on({
    		tap: 'onLoginTap',
    		scope: this
    	});

    	/*var xxx = this.down('container#xxx');

    	var field = Ext.widget('textfield', {

    		label: 'xxx'
    	});
    	xxx.insert(1, field);*/
    },

    onLoginTap: function(btn, e){
    	this.fireEvent('taplogin', this, btn, e);
    },

    onInit: function(){

    }
});